import 'package:flutter/material.dart';
import 'package:flutter_demo/ui/pages/status/data/share_data.dart';
import 'package:flutter_demo/ui/pages/status/inherited/update/a1_page_widget.dart';
import 'package:flutter_demo/ui/pages/status/inherited/update/b1_page_widget.dart';
import 'package:flutter_demo/ui/pages/status/inherited/update/share_update_widget.dart';

/*
 * InheritedWidget重建后悔自动触发InheritElement的Update方法。
  缺点：
  无法分离视图逻辑和业务逻辑。
  无法定向通知/指向性通知。
 */
class InheritedUpdateTestWidget extends StatefulWidget {
  InheritedUpdateTestWidget({super.key});
  ShareData shareData = ShareData(nickname: "初始值", level: 11);

  @override
  State<InheritedUpdateTestWidget> createState() => _InheritedUpdateTestState();
}

class _InheritedUpdateTestState extends State<InheritedUpdateTestWidget> {
  @override
  Widget build(BuildContext context) {
    return ShareUpdateWidget(
      shareData: widget.shareData,
      //child: MaterialApp(home: APage()),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [A1PageWidget(), B1PageWidget()],
      ),
    );
  }
}
